# from sqlalchemy.dialects.mysql import MEDIUMTEXT
# from sqlalchemy.orm import scoped_session, sessionmaker, declarative_base
# from sqlalchemy import create_engine, Column, Integer, String, UniqueConstraint, Text, exc, DateTime, inspect, ARRAY, \
#     or_, and_, JSON, DATETIME
#
# # 创建基类
# Base = declarative_base()
# # 定义模型
# class Project_Table(Base):
#     __tablename__ = 'material'
#     材料ID = Column(Integer, primary_key=True, autoincrement=True)  # 自增主键
#     问题ID = Column(Integer)
#     材料顺序 = Column(Integer)
#     材料类型 = Column(MEDIUMTEXT)
#     材料内容 = Column(MEDIUMTEXT)
#
#     __table_args__ = (
#         UniqueConstraint('问题ID', '材料顺序', name='唯一值'),
#     )
#
# # 创建数据库引擎和会话
# DATABASE_URI = 'mysql+pymysql://root:grow1234@nj-cdb-1mwvwkzt.sql.tencentcdb.com:63972/stock_exchange'
# POOL_SIZE = 200
# MAX_OVERFLOW = 300
# engine = create_engine(DATABASE_URI, pool_size=POOL_SIZE, max_overflow=MAX_OVERFLOW)
#
# # 检查表格是否已存在
# inspector = inspect(engine)
# if not inspector.has_table("material"):
#     # 表格不存在，创建表格
#     Base.metadata.create_all(engine)
#     print('表格已成功创建')
# else:
#     # 表格已存在
#     print('表格已存在，无需创建')
#
# # 假设engine是预先创建好的数据库引擎
# DBSession = scoped_session(sessionmaker(bind=engine))
# 类别，文件名，时间，轮次，